package com.putao.album.util;

import android.app.Activity;
import android.view.View;

/**
 * Created by jidongdong on 15/5/6.
 */
public class ViewHelper {

    /**
     * 获取某一个View中的子View
     *
     * @param activity
     * @param viewId
     * @param <T>
     * @return
     */
    public static <T extends View> T queryViewById(Activity activity, int viewId) {
        if (viewId > 0 && activity != null) {
            return (T) activity.findViewById(viewId);
        }
        return null;
    }


    /**
     * 获取某一个View中的子View
     *
     * @param parent
     * @param viewId
     * @param <T>
     * @return
     */
    public static <T extends View> T queryViewById(View parent, int viewId) {
        if (viewId > 0 && parent != null) {
            return (T) parent.findViewById(viewId);
        }
        return null;
    }

}
